#ifndef _KGGLOBALDATA_H
#define _KGGLOBALDATA_H
#include <QObject>
#include <QList>
#include <QDateTime>
#include <QTcpSocket>
#include <qfileinfo.h>  
#include "KgLogFile.h"
#include "xnserial.h"
#include "xncan.h"
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QCoreApplication>
#include <cfloat>

#define DEV_PATH    "../ini/BA10.ini" //"../ini/" + QCoreApplication::applicationName() + ".ini"
#define DEVTEMP_PATH    "../ini/BA10Temp.ini" //"../ini/" + QCoreApplication::applicationName() + "Temp.ini"

class CRTDB;
class KgGlobalData
{
public:
    KgGlobalData(void);
    ~KgGlobalData(void);

    static QMutex m_mutex;
    static QSqlDatabase m_dataBase;
    static void sqlConfig(void);
};

void saveLogToBaDb(QString strLog);
void addToBuff(char *pData,quint16 u16Val);
void getFromBuff(char *pData,quint8 &u8Val);
void getFromBuff(char *pData,quint16 &u16Val);
void getFromBuff(char *pData,quint32 &u32Val);
void getFromBuff(char *pData,quint64 &u64Val);
quint16 swapBytes(quint16 u16Val);
float getFloat(unsigned long data);
double getDouble(unsigned long data);
signed int get645Data(quint8 dataLen, char *pRecv);
quint16 Modbus_CRC16(uchar *dat_buf,uchar dat_len);
quint8 Em645_CRC8(uchar *dat_buf,uchar dat_len);

#endif
